package com.hontech.bvapp2.ui.parts.heat

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.Button
import android.widget.FrameLayout
import com.hontech.bvapp2.R
import com.hontech.bvapp2.device.cp.Heat
import com.hontech.bvapp2.ui.dialog.runProg
import com.hontech.bvapp2.utils.onClick

class HeatVCtrlParts (context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {

    init {
        val view = LayoutInflater.from(context).inflate(R.layout.parts_heat_v_ctrl, this)

        val clampOpen = view.findViewById<Button>(R.id.id_heat_v_clamp_open)
        val clampClose = view.findViewById<Button>(R.id.id_heat_v_clamp_close)
        val trunMove = view.findViewById<Button>(R.id.id_heat_v_trun_move)
        val trunReset = view.findViewById<Button>(R.id.id_heat_v_trun_reset)

        clampOpen.onClick {
            runProg("夹管阀", "打开") {
                Heat.clampCtrl(0)
            }
        }

        clampClose.onClick {
            runProg("夹管阀", "关闭") {
                Heat.clampCtrl(1)
            }
        }

        trunMove.onClick {
            runProg("截流阀", "移开") {
                Heat.trunCtrl(0)
            }
        }

        trunReset.onClick {
            runProg("截流阀", "复位") {
                Heat.trunCtrl(1)
            }
        }
    }
}